<?php
namespace app\index\controller;

use app\common\model\Chat;
use app\common\model\Info;
use app\common\model\Qqjob;
use app\common\model\Qqs;
use app\common\model\Gg;
use app\common\model\Pays;
use app\common\model\Users;
use app\common\model\Weblist;
use app\common\model\Prizes;
use app\common\model\Prizelog;
use app\common\model\Qds;
use app\common\model\Jfdh;

class UserAjax extends Ajax
{
	public function shop($act)
    {
        if (request()->isAjax()) {
            $result = [
                'code' => -1,
                'message' => '无此操作'
            ];
            switch ($act) {
                case 'price':
                    $data = input('post.');
                    switch ($data['type']) {
                        case 'vip':
                            //判断站点是否开启商品促销
                            if (config('sys_is_shop_vip_zk') == 1) {
                                //计算折扣后的价格
                                $price = config('sys_' . $data['type'] . '_price_' . $data['id']);
                                $zk = config('sys_shop_' . $data['type'] . '_zk_' . $data['id'] . '');
                                $res = round($price * $zk / 10, 2);
								echo "<script>$(\"#vipktjiage\").html('<font class=\"bold pr0\">开通价格：</font><font class=\"f6 hong\">".$res."</font> 元 <font class=\"f3 hui\">原价<s> ".$price." </s>元 ".$zk."折优惠中</font>');</script>";
                            } else {
								echo "<script>$(\"#vipktjiage\").html('<font class=\"bold pr0\">开通价格：</font><font class=\"f6 hong\">".config('sys_' . $data['type'] . '_price_' . $data['id'])."</font> 元');</script>";
                            }
                            break;
                        case 'pe':
                            //判断站点是否开启商品促销
                            if (config('sys_is_shop_pe_zk') == 1) {
                                //计算折扣后的价格
                                $price = config('sys_' . $data['type'] . '_price_' . $data['id']);
                                $zk = config('sys_shop_' . $data['type'] . '_zk_' . $data['id'] . '');
                                $res = round($price * $zk / 10, 2);
                                echo "<script>$(\"#pektjiage\").html('<font class=\"bold pr0\">开通价格：</font><font class=\"f6 hong\">".$res."</font> 元 <font class=\"f3 hui\">原价<s> ".$price." </s>元 ".$zk."折优惠中</font>');</script>";
                            } else {
                                echo "<script>$(\"#pektjiage\").html('<font class=\"bold pr0\">开通价格：</font><font class=\"f6 hong\">".config('sys_' . $data['type'] . '_price_' . $data['id'])."</font> 元');</script>";
                            }
                            break;
                        case 'dl':
							echo "<script>$(\"#dlktjiage\").html('<font class=\"bold pr0\">开通价格：</font><font class=\"f6 hong\">".config('sys_daili_price_'.$data['id'].'')."</font> 元');</script>";
                            break;
                    }
                    break;
                case 'vip':
                    $data = input('post.');
                    if ($data['pay_type'] == 'ypay') {
						$json=Users::YpayVip($this->userInfo, $data);
                        if(check_mobile()){
							echo moblie_msg('返回信息',$json['message']);
						}else{
							echo pc_msg('返回信息',$json['message']);
						}
                    } else {
                        echo Pays::Submit_Pay($this->userInfo, $data);
                    }
                    break;
                case 'peie':
                    $data = input('post.');
                    if ($data['pay_type'] == 'ypay') {
                        $json=Users::YpayPeie($this->userInfo, $data);
						if(check_mobile()){
							echo moblie_msg('返回信息',$json['message']);
						}else{
							echo pc_msg('返回信息',$json['message']);
						}
							
                    } else {
                        echo Pays::Submit_Pay($this->userInfo, $data);
                    }
                    break;
                case 'dl':
                    $data = input('post.');
                    echo Pays::Submit_Pay($this->userInfo, $data);
                    break;
                case 'rmb':
                    $data = input('post.');
                    echo Pays::Submit_Pay($this->userInfo, $data);
                    break;
                case 'fz':
                    $data = input('post.');
					dump(Pays::Submit_Pay($this->userInfo, $data));
                    echo Pays::Submit_Pay($this->userInfo, $data);
                    break;
            }
        }
    }
	
	public function addfz($act)
    {
        switch ($act) {
            case 'price':
                $time = input('post.time');
                $price = config('sys_fz_price_' . $time);
				echo "<script>$(\"#fzktjiage\").html('<font class=\"bold pr0\">开通价格：</font><font class=\"f6 hong\">".$price."</font> 元');</script>";
                break;
        }
    }
	
	public function newpwd()
    {
        $data = input('post.');
        $userInfo = Users::getLoginUser();
        switch (true) {
            case (!$this->geetest_check($data['geetest_challenge'], $data['geetest_validate'], $data['geetest_seccode'])):
                $result['message'] = '验证码效验失败，请重试！';
                break;
            default;
                $result = Users::change_Password($userInfo['uid'],$data);
                break;
        }
        return $result;
    }
	
	public function newname()
    {
        $data = input('post.');
        $userInfo = Users::getLoginUser();
        switch (true) {
            case (!$this->geetest_check($data['geetest_challenge'], $data['geetest_validate'], $data['geetest_seccode'])):
                $result['message'] = '验证码效验失败，请重试！';
                break;
            default;
				$rule=[
					'name'  => 'require|length:2,20',
				];
				$message=[
					'name.require'=>'昵称不能为空',
					'name.length'=>'昵称长度必须在5到20之间'
				];
				
				$validate=new \think\Validate($rule,$message);
				if(!$validate->check($data)){
					$result = [
								'code' => -1,
								'message' => $validate->getError()
							];
				}else{
					$result = Users::change_Nickname($this->userInfo['uid'],$data);
				}
                break;
        }
        return $result;
    }
	
	public function newqq()
    {
        $data = input('post.');
        $userInfo = Users::getLoginUser();
        switch (true) {
            case (!$this->geetest_check($data['geetest_challenge'], $data['geetest_validate'], $data['geetest_seccode'])):
                $result['message'] = '验证码效验失败，请重试！';
                break;
            default;
				$rule=[
					'qq'    => 'require|number|length:4,13'
				];
				$message=[
					'qq.require'=>"QQ不能为空",
					'qq.number'=>"QQ只能数字",
					'qq.length'=>"QQ长度必须在4到13之间",
				];
				
				$validate=new \think\Validate($rule,$message);
				if(!$validate->check($data)){
					$result = [
								'code' => -1,
								'message' => $validate->getError()
							];
				}else{
					$result = Users::change_Qq($this->userInfo['uid'],$data);
				}
                break;
        }
        return $result;
    }
	
    public function countList($action)
    {
        if (request()->isAjax()) {
            $result = [
                'code' => -1,
                'message' => '无此操作'
            ];
            switch ($action) {
                case 'gg':
                    $select = Gg::search();
                    if (false === $select) {
                        $result['message'] = '获取列表失败，请稍后再试';
                    } elseif (is_string($select)) {
                        $result['message'] = $select;
                    } else {
                        $result = [
                            'code' => 0,
                            'message' => 'success',
                            'total' => $select['total'],
                            'list' => $select['list']
                        ];
                    }
                break;
				case 'mzqq':
					$load_list = Qqjob::where('type', '=', 'zan')
					->where('zid', '=', WEB_ID)
					->order('lasttime desc')
					->limit(200)
					->select();
					$total = 0;
					$list = [];
					if ($load_list) {
						foreach ($load_list as $key=>$qq) {
							$list[$key]=$qq;
							$list[$key]['img']='https://q4.qlogo.cn/headimg_dl?dst_uin='.$qq['qq'].'&spec=100';
							$list[$key]['url']='tencent://AddContact/?fromId=45&amp;fromSubId=1&amp;subcmd=all&amp;uin='.$qq['qq'].'&amp;website='.config('web_domain');
							$total=$total+1;
						}
					}
					$result = [
                        'code' => 0,
                        'message' => 'success',
                        'total' => $total,
                        'list' => $list
                    ];
                break;
			case 'mzph':
					$load_list = Qqjob::mzphb();
					$total = 0;
					$list = [];
					if ($load_list) {
						foreach ($load_list as $key=>$qq) {
							$list[$key]=$qq;
							$list[$key]['img']='https://q4.qlogo.cn/headimg_dl?dst_uin='.$qq['qq'].'&spec=100';
							$list[$key]['url']='tencent://AddContact/?fromId=45&amp;fromSubId=1&amp;subcmd=all&amp;uin='.$qq['qq'].'&amp;website='.config('web_domain');
							$total=$total+1;
							$list[$key]['mzcount']=Qqjob::where('type', '=', 'zan')
							->where('qq', '=', $qq['qq'])
							->where('zid', '=', WEB_ID)
							->sum('times');
						}
					}
					$result = [
                        'code' => 0,
                        'message' => 'success',
                        'total' => $total,
                        'list' => $list
                    ];
                break;
            }
        }
        return $result;
    }
	
	public function chat($act)
    {
        switch ($act) {
            case 'send':
                $timelimit = config('sys_timelimit'); //时间周期(秒)
                $iplimit = config('sys_iplimit'); //相同IP在1个时间周期内限制发言的次数
                $timelimits = date("Y-m-d H:i:s", time() - $timelimit);
				$zishu = config('sys_zishu');
                $ipcount = Chat::where('sendtime', '>', $timelimits)
                    ->where('sendip', '=', real_ip())
                    ->count();
                $con = input('post.chatcon');
                if (!$timelimit || !$iplimit || !$zishu) {
                    $result = [
						'type' => 0,
						'uid'  => $this->userInfo['uid'],	
                        'error' => '站长还没有配置好聊天室信息，等会再来吧！'
                    ];
                    return $result;
                }
				$con = substr($con , 0 , config('sys_zishu'));
                if ($con != '') {
                    $is_jy = back_list($con);
                    if ($is_jy == 1) {
                        $result = [
							'type' => 0,
						    'uid'  => $this->userInfo['uid'],	
                            'error' => '内容包含敏感词汇，请修改后提交！'
                        ];
                    } elseif ($is_jy > 1) {
                        cookie('chat_back', 1, config('sys_jy_s'));
                        cookie('back_con', $con, config('sys_jy_s'));
                        $backtime = config('sys_jy_s') / 60;
                        $backdate = date('Y-m-d H:i:s', strtotime('+' . $backtime . ' minute'));
						$result = [
							'type' => 0,
						    'uid'  => $this->userInfo['uid'],	
                            'error' => '您已被系统临时禁言' . $backtime . '分钟,请勿辱骂广告和违规操作'
                        ];
                    } elseif (cookie('chat_back') == 1) {
                        $backtime = config('sys_jy_s') / 60;
                        $backdate = date('Y-m-d H:i:s', strtotime('+' . $backtime . ' minute'));
                        $result = [
							'type' => 0,
						    'uid'  => $this->userInfo['uid'],	
                            'error' => '您已被系统临时禁言' . $backtime . '分钟,请勿辱骂广告和违规操作'
                        ];
                    } else if ($ipcount >= $iplimit) {
                        $result = [
							'type' => 0,
						    'uid'  => $this->userInfo['uid'],	
                            'error' => '您的发言速度太快了，不要刷屏哦'
                        ];
                    } else {
                        $add_find = [
                            'uid' => $this->userInfo['uid'],
							'zid' => WEB_ID,
                            'qq' => $this->userInfo['qq'],
                            'nickname' => $this->userInfo['nickname'],
                            'content' => $con,
                            'time' => time(),
                            'sendtime' => $this->date,
                            'sendip' => real_ip()
                        ];
                        $add_res = Chat::insert($add_find);
                        if ($add_res) {
							
                            $row = Chat::where('uid', '=', $this->userInfo['uid'])->order('id desc')->find();
                            $user = $this->userInfo;
                            $diff = timediff(strtotime($user['vipstart']), strtotime($user['viptime']));
							$color = 'hong';
							if($user && $diff < 1 && $user['dlpower'] == 0){
								$color = '';
								$pc_sf = '';
								$m_sf = '';
							}elseif($user && $diff < 30 && $user['dlpower'] == 0){
								$color = '';
								$pc_sf = '<span class="bg-lan f3 pl1 pr1 rx1 ml2">体验VIP</span>';
								$m_sf = '<span class="bg-lan pl1 pr1 rx1 mr1">体验VIP</span>';
							}elseif($user && $diff > 29 && $diff < 90 && $user['dlpower'] == 0) {
								$pc_sf = '<span class="bg-lan f3 pl1 pr1 rx1 ml2">包月VIP</span>';
								$m_sf = '<span class="bg-lan pl1 pr1 rx1 mr1">包月VIP</span>';
							}elseif($user && $diff > 89 && $diff < 180 && $user['dlpower'] == 0) {
								$pc_sf = '<span class="bg-lan f3 pl1 pr1 rx1 ml2">包季VIP</span>';
								$m_sf = '<span class="bg-lan pl1 pr1 rx1 mr1">包季VIP</span>';
							}elseif($user && $diff > 179 && $diff < 365 && $user['dlpower'] == 0) {
								$pc_sf = '<span class="bg-zi f3 pl1 pr1 rx1 ml2">包季VIP2</span>';
								$m_sf = '<span class="bg-zi pl1 pr1 rx1 mr1">包季VIP2</span>';
							}elseif($user && $diff > 364 && $user['dlpower'] == 0) {
								$pc_sf = '<span class="bg-huang f3 pl1 pr1 rx1 ml2">年费VIP</span>';
								$m_sf = '<span class="bg-huang pl1 pr1 rx1 mr1">年费VIP</span>';
							}elseif($user['dlpower'] == 1) {
								$pc_sf = '<span class="bg-lan f3 pl1 pr1 rx1 ml2">银牌代理</span>';
								$m_sf = '<span class="bg-lan pl1 pr1 rx1 mr1">银牌代理</span>';
							}elseif($user['dlpower'] == 2) {
								$pc_sf = '<span class="bg-huang f3 pl1 pr1 rx1 ml2">金牌代理</span>';
								$m_sf = '<span class="bg-huang pl1 pr1 rx1 mr1">金牌代理</span>';
							}elseif($user['dlpower'] == 3) {
								$pc_sf = '<span class="bg-huang f3 pl1 pr1 rx1 ml2">钻石代理</span>';
								$m_sf = '<span class="bg-huang pl1 pr1 rx1 mr1">钻石代理</span>';
							}elseif($user['dlpower'] == 1) {
								$color = '';
								$pc_sf = '';
								$m_sf = '';
							}
							$mobile_mymsg='<dl class="pt2 pb3"><dt><p class="w10"></p></dt><dd class="t-r"><p class="f2">'.$m_sf.'<font class="'.$color.' bold" >' . $row['nickname'] . '</font></p><p><span class="inline bg-lan dl2 p2 rx3 copy" data-clipboard-text="' . $row['content'] . '">' . $row['content'] . '</span></p></dd><dt><p class="w10 t-c"><img class="w7 h7 b r5" src="https://q4.qlogo.cn/headimg_dl?dst_uin=' . $row['qq'] . '&spec=100"></p></dt></dl>';
							
						    $mobile_msg='<dl class="pt2 pb3"><dt><p class="w10 t-c"><img class="w7 h7 b r5" src="https://q4.qlogo.cn/headimg_dl?dst_uin=' . $row['qq'] . '&spec=100" onclick="chat_mode_footer(\'' . $row['nickname'] . '\',\'' . $row['qq'] . '\')"></p></dt> <dd> <p class="f2">'.$m_sf.'<font class="'.$color.' bold" >' . $row['nickname'] . '</font></p> <p><span class="inline bg-bai dl2 p2 rx3 copy" data-clipboard-text="' . $row['content'] . '">' . $row['content'] . '</span></p> </dd> <dt><p class="w10"></p></dt> </dl>';
							
						    $pc_msg='<dl>
							<dt><img class="w9 h9 b r5 mr3" src="http://q1.qlogo.cn/g?b=qq&amp;nk=' . $row['qq'] . '&amp;s=100&amp;t=327">
							</dt>
							<dt><p class=""><font class="'.$color.' bold"><i class="icon icon-my"></i> ' . $row['nickname'] . '</font>'.$pc_sf.' ：</p><p class="f3 hui"><i class="icon icon-time nobold"></i> '.time_tran($row['sendtime']).'</p></dt>
							<dd><font class="">' . $row['content'] . '</font></dd>
							</dl>';
							
							$result = [
								'code' => 0,
								'type' => 1,
								'uid'  => $this->userInfo['uid'],
								'domain' => config('web_domain'),
								'zid'  => WEB_ID,	
								'Mobile_Msg_my' => $mobile_mymsg,
								'Mobile_Msg_you' => $mobile_msg,
								'Pc_Msg' => $pc_msg,
							];
                        }
                    }
                } else {
                    $result = [
						'type' => 0,
						'uid'  => $this->userInfo['uid'],	
                        'error' => '请输入聊天内容！'
                    ];
                }
               return $result;
                break;
			case 'load':
				$type = is_numeric(input('post.type')) ? input('post.type') : 'web';
                $list ='';
				$id = is_numeric(input('post.id')) ? input('post.id') : '0';
                $data = Chat::where('id', '>', $id)
				->where('zid', '=', WEB_ID)
                ->order('sendtime')
                ->select();
				if ($data) {
					foreach ($data as $row) {
                        $user = Users::where('uid', '=', $row['uid'])->find();
                        $diff = timediff(strtotime($user['vipstart']), strtotime($user['viptime']));
						$color = 'hong';
						if($user && $diff < 1 && $user['dlpower'] == 0){
							$color = '';
							$pc_sf = '';
							$m_sf = '';
						}elseif($user && $diff < 30 && $user['dlpower'] == 0){
							$color = '';
							$pc_sf = '<span class="bg-lan f3 pl1 pr1 rx1 ml2">体验VIP</span>';
							$m_sf = '<span class="bg-lan pl1 pr1 rx1 mr1">体验VIP</span>';
						}elseif($user && $diff > 29 && $diff < 90 && $user['dlpower'] == 0) {
							$pc_sf = '<span class="bg-lan f3 pl1 pr1 rx1 ml2">包月VIP</span>';
							$m_sf = '<span class="bg-lan pl1 pr1 rx1 mr1">包月VIP</span>';
						}elseif($user && $diff > 89 && $diff < 180 && $user['dlpower'] == 0) {
							$pc_sf = '<span class="bg-lan f3 pl1 pr1 rx1 ml2">包季VIP</span>';
							$m_sf = '<span class="bg-lan pl1 pr1 rx1 mr1">包季VIP</span>';
						}elseif($user && $diff > 179 && $diff < 365 && $user['dlpower'] == 0) {
							$pc_sf = '<span class="bg-zi f3 pl1 pr1 rx1 ml2">包季VIP2</span>';
							$m_sf = '<span class="bg-zi pl1 pr1 rx1 mr1">包季VIP2</span>';
						}elseif($user && $diff > 364 && $user['dlpower'] == 0) {
							$pc_sf = '<span class="bg-huang f3 pl1 pr1 rx1 ml2">年费VIP</span>';
							$m_sf = '<span class="bg-huang pl1 pr1 rx1 mr1">年费VIP</span>';
						}elseif($user['dlpower'] == 1) {
							$pc_sf = '<span class="bg-lan f3 pl1 pr1 rx1 ml2">银牌代理</span>';
							$m_sf = '<span class="bg-lan pl1 pr1 rx1 mr1">银牌代理</span>';
						}elseif($user['dlpower'] == 2) {
							$pc_sf = '<span class="bg-huang f3 pl1 pr1 rx1 ml2">金牌代理</span>';
							$m_sf = '<span class="bg-huang pl1 pr1 rx1 mr1">金牌代理</span>';
						}elseif($user['dlpower'] == 3) {
							$pc_sf = '<span class="bg-huang f3 pl1 pr1 rx1 ml2">钻石代理</span>';
							$m_sf = '<span class="bg-huang pl1 pr1 rx1 mr1">钻石代理</span>';
						}else{
							$color = '';
							$pc_sf = '';
							$m_sf = '';
						}
						if($type == 'web'){
							$list .= '<dl>
							<dt><img class="w9 h9 b r5 mr3" src="http://q1.qlogo.cn/g?b=qq&amp;nk=' . $row['qq'] . '&amp;s=100&amp;t=327">
							</dt>
							<dt><p class=""><font class="'.$color.' bold"><i class="icon icon-my"></i> ' . $row['nickname'] . '</font>'.$pc_sf.' ：</p><p class="f3 hui"><i class="icon icon-time nobold"></i> '.time_tran($row['sendtime']).'</p></dt>
							<dd><font class="">' . $row['content'] . '</font></dd>
							</dl>';
						}else{
							if ($row['uid'] !== $userInfo['uid']) {
								$list .= '<dl class="pt2 pb3"><dt><p class="w10"></p></dt><dd class="t-r"><p class="f2">'.$m_sf.'<font class="'.$color.' bold" >' . $row['nickname'] . '</font></p><p><span class="inline bg-lan dl2 p2 rx3 copy" data-clipboard-text="' . $row['content'] . '">' . $row['content'] . '</span></p></dd><dt><p class="w10 t-c"><img class="w7 h7 b r5" src="https://q4.qlogo.cn/headimg_dl?dst_uin=' . $row['qq'] . '&spec=100"></p></dt></dl>';
							}elseif($row['uid'] == $userInfo['uid']){
								$list .= '<dl class="pt2 pb3"><dt><p class="w10 t-c"><img class="w7 h7 b r5" src="https://q4.qlogo.cn/headimg_dl?dst_uin=' . $row['qq'] . '&spec=100" onclick="chat_mode_footer(\'' . $row['nickname'] . '\',\'' . $row['qq'] . '\')"></p></dt> <dd> <p class="f2">'.$m_sf.'<font class="'.$color.' bold" >' . $row['nickname'] . '</font></p> <p><span class="inline bg-lan dl2 p2 rx3 copy" data-clipboard-text="' . $row['content'] . '">' . $row['content'] . '</span></p> </dd> <dt><p class="w10"></p></dt> </dl>';
							}
						}
					}
				}
				$list .='<js><script>ChatScroolToEnd();</script></js>';
				echo $list;
                break;
       }
    }
	
	public function Gnset($act)
    {
        if (request()->isAjax()) {
            $result = [
                'code' => -1,
                'message' => '无此操作'
            ];
            switch ($act) {
                case 'upload':
                    $qid = input('post.qid');
                    $act = input('post.act');
                    $file = request()->file('f');
                    $info = $file->validate([
                        'size' => 512000,
                        'ext' => 'jpg,png,jpeg',
                        'type' => 'image/jpeg,image/png'])->move(ROOT_PATH . 'static/uploads');
                    $a = $info->getSaveName();
                    $imgp = str_replace("\\", "/", $a);
                    $imgpath = get_domain() . 'static/uploads/' . $imgp;
                    Qqjob::
                    where('qid', '=', $qid)
                        ->where('type', '=', $act)
                        ->update(['url' => $imgpath]);
                    $result = array();
                    if ($info) {
                        $result['isSuccess'] = true;
                        $result['f'] = $imgpath;
                    } else {
                        $result['isSuccess'] = false;
                    }
                    break;
			}
		}
		echo json_encode($result);
    }
	
	public function other($act)
    {
        if (request()->isAjax()) {
            $result = [
                'code' => -1,
                'message' => '无此操作'
            ];
            switch ($act) {
                case 'jfdh':
                    $type = input('post.type');
                    $need_jf = config('sys_jfdh_' . $type . '_jf');
                    $dh_shop = config('sys_jfdh_' . $type . '_num');
                    $result = Jfdh::jfdh(
                        $this->userInfo,
                        [
                            'jf' => $need_jf,
                            'shop' => $dh_shop,
                            'type' => $type
                        ]
                    );
					if(check_mobile()){
						echo moblie_msg('返回信息',$result['message']);
					}else{
						echo pc_msg('返回信息',$result['message']);
					}
                    break;
                case 'jfdhList':
                    $select = Jfdh::search(WEB_ID);
                    if (false === $select) {
                        $result['message'] = '获取列表失败，请稍后再试';
                    } elseif (is_string($select)) {
                        $result['message'] = $select;
                    } else {
                        $result = [
                            'code' => 0,
                            'message' => 'success',
                            'total' => $select['total'],
                            'list' => $select['list']
                        ];
                    }
                    break;
                case 'qds':
                    $qid = input('post.qid');
                    $result = Qds::submit($this->userInfo, $qid);
					if(check_mobile()){
						echo moblie_msg('返回信息',$result['message']);
					}else{
						echo pc_msg('返回信息',$result['message']);
					}
                    break;
                case 'qdList':
                    $select = Qds::search();
                    if (false === $select) {
                        $result['message'] = '获取列表失败，请稍后再试';
                    } elseif (is_string($select)) {
                        $result['message'] = $select;
                    } else {
                        if (Qds::isTodayQds($this->userInfo['uid']) == true) {
                            $result = [
                                'code' => -1,
                                'jf' => $this->userInfo['jf'],
                                'alert' => '<button class="btn btn-hui btn-md w22 rx1" onclick="x.msg(\'您今日已经签过到了哦\');">今 日 已 签 到</button>',
                                'total' => $select['total'],
                                'list' => $select['list']
                            ];
                        } else {
                            $result = [
                                'code' => 0,
                                'jf' => $this->userInfo['jf'],
                                'total' => $select['total'],
                                'list' => $select['list']
                            ];
                        }
                    }
                    break;
                case 'cjs':
                    $now_time = date('H', time());
                    if ($now_time < config('sys_cj_kf_time')) {
                        $result = [
                            'code' => 1,
                            'message' => '抽奖活动暂未开放，开放时间：' . date('m-d') . ' ' . config('sys_cj_kf_time') . ':00:00'
                        ];
                    } else {
                        $result = Prizes::cj($this->userInfo);
                    }
					if(check_mobile()){
						echo moblie_msg('返回信息',$result['message']);
					}else{
						echo pc_msg('返回信息',$result['message']);
					}
                    break;
                case 'cjList':
                    $select = Prizelog::search();
                    if (false === $select) {
                        $result['message'] = '获取列表失败，请稍后再试';
                    } elseif (is_string($select)) {
                        $result['message'] = $select;
                    } else {
                        $result = [
                            'code' => 0,
                            'jf' => $this->userInfo['jf'],
                            'total' => $select['total'],
                            'list' => $select['list']
                        ];
                    }
                    break;
                case 'promsg':
                    if (!empty($this->userInfo['qq']) && !empty($userInfo['mail'])) {
                        $result = [
                            'code' => 0
                        ];
                    } else {
                        $result = [
                            'code' => 1,
                            'message' => '您还没有完善资料，是否现在完善？'
                        ];
                    }
                    break;
            }
        }
        return $result;
    }
	
	protected
    function _initialize()
    {
        parent::_initialize();
        $this->checkLogin();
		
    }
	
	private
    function checkLogin()
    {
        $check_Login = Users::checkLogin();
        if ($check_Login != null) {
			$this->assign('alert', $check_Login['msg']);
            $this->assign('url', $check_Login['url']);
            exit($this->fetch('pc/common/msg'));
        } else {
            $this->userInfo = Users::getLoginUser();
            $this->assign('userInfo', $this->userInfo);

        }
    }
}